<?php
/*
Template Name: Portfolio
*/
?>							
              <?php get_header();?>
              <div id="main-portfolio">								
								<div id="maintext">
								  <?php if ( have_posts() ) :?>
              		  <?php display_subtitle();?>	
                    
                    <div class="clr"></div>	<br />
                    <ul id="filter">
                    <?php
                			 $portfolio_page = get_option('centita_portfolio_page');
                			 $portfolio_pid = get_page_by_title($portfolio_page);
                			 ?>
             			      <li><a class="<?php if (!get_query_var('portfolio_category')) echo 'current'; ?>" href="<?php echo get_page_link($portfolio_pid->ID);?>"><?php echo __('All','ecobiz');?></a></li>
                      	<?php  
                        $categories = get_categories('taxonomy=portfolio_category&orderby=ID&title_li=&hide_empty=0');
                        foreach ($categories as $category) { 
                        $termlink = get_term_link($category->slug,$category->taxonomy);
                        ?>
                          <li><a  class="<?php if (get_query_var($category->taxonomy) == $category->slug) echo 'current'; ?>" href="<?php echo $termlink;?>"><?php echo $category->name;?></a></li>
                          <?php
                        }
                        ?>
                      </ul>                     
                      <?php 
                        $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
                        $portfolio_items_num  = (get_option('centita_porto_num')) ? get_option('centita_porto_num') : 8; 
                        $portfolio_order = (get_option('centita_portfolio_order')) ? get_option('centita_portfolio_order') : "date";
                        
                        query_posts(array( 'post_type' => 'portfolio', 'showposts' => $portfolio_items_num,'paged'=>$page,"orderby" => $portfolio_order,'order'=> 'DESC'));
                        
                        $counter = 0;
                        while ( have_posts() ) : the_post();
                        $counter++;
                        $pf_link = get_post_meta($post->ID, '_portfolio_link', true );
                        $pf_url = get_post_meta($post->ID, '_portfolio_url', true );
                        ?>          
          	         <div <?php if ($counter %4 ==0) echo 'class="box-pf-last-top"'; else echo 'class="box-pf-top"'?>>                                   
                     <?php if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {?>
                        <a href="<?php echo ($pf_link) ? $pf_link : thumb_url();?>" rel="prettyPhoto[pf]">
                          <img src="<?php echo get_template_directory_uri();?>/timthumb.php?src=<?php echo thumb_url();?>&amp;h=134&amp;w=220&amp;zc=1" alt="" />
                        </a>
                      <?php } ?>
                      <strong><a href="<?php the_permalink();?>"><?php the_title();?></a></strong>
                    </div>
                    <?php if ($counter %4 ==0) echo '<div class="clr"></div>';?>
      						<?php endwhile;?>
      						<?php endif;?>   
                  <div class="clr"></div>
            				<?php 
            				  if (function_exists('wp_pagenavi')) :
            				    wp_pagenavi();
            				  else : 
            				?>
                  		<div class="navigation">
                  			<div class="alignleft"><?php next_posts_link(__('&laquo; Previous Entries','centita')) ?></div>
                  			<div class="alignright"><?php previous_posts_link(__('Next Entries &raquo;','centita')) ?></div>
                  			<div class="clear"></div>
                  		</div>
                    <?php endif;?>  
                                 				
                    <div class="clr"></div>
                    <div class="h-line"><hr /></div>
                    <div class="quote">
                    
                    <?php 
                      $getquote_title = get_option('centita_getquote_title'); 
                      $getquote_icon = get_option('centita_getquote_icon');
                      $getquote_text = get_option('centita_getquote_text');
                      $contacentita_email = get_option('centita_info_email');
                    ?>
                    <img src="<?php echo $getquote_icon ? $getquote_icon : get_template_directory_uri().'/images/quote-paper.jpg';?>" alt="" class="imgleft" />
                    <h2><?php echo $getquote_title ? $getquote_title :"Get a free Quote";?></h2>
                    <?php if ($getquote_text !="") echo "<p>$getquote_text</p>";?> 
                    </div>                      
        	       </div><!-- end of maintext -->
							</div><!-- end of main -->
								<?php get_footer();?>